﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="open_Folder.aspx.cs" Inherits="SQT.tracnghiem.Ajax.ASP.Gallery.open_Folder" %>

<%@ Import Namespace="DataAccess" %>
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <table class="gal-table-head w3-table w3-bordered">
        <thead>
            <tr>
                <td class="gal-table-name gal-table-sort-name"><i class="fa fa-chevron-down"></i>Tên</td>
                <td class="gal-table-date gal-table-sort-date">Ngày tạo</td>
                <td class="gal-table-modified gal-table-sort-modified">Thay đổi lần cuối</td>
                <td class="gal-table-options">Tùy chọn</td>
            </tr>
        </thead>
    </table>

    <table class="gal-table-data w3-table w3-white">
        <tbody id="item_area">
            <%
                int id = int.Parse(Request.QueryString["id"]);
                var get_folder = new TblLibraryController().FetchAll().Where(x => x.LibraryTrash == false && x.LibraryDelete == false && x.LibraryParent == id && x.LibraryType == 0); %>
            <%foreach (TblLibrary folder in get_folder)
              {
                  var get_uploader = new TblManagerController().FetchAll().Where(x => x.ManagerId == folder.LibraryUploader).Single();
                  var get_editor = new TblManagerController().FetchAll().Where(x => x.ManagerId == folder.LibraryEditor).Single();
                  string upload_date = "", edit_date = "";
                  DateTime date = DateTime.Parse(folder.LibraryUploadDate.ToString());
                  upload_date = date.Day + "/" + date.Month + "/" + date.Year + " " + date.Hour + ":" + date.Minute;
                  date = DateTime.Parse(folder.LibraryEditDate.ToString());
                  edit_date = date.Day + "/" + date.Month + "/" + date.Year + " " + date.Hour + ":" + date.Minute;
            %>
            <tr id="item<%=folder.LibraryId %>">
                <td ondblclick="gal_open_menu_left(event, 'allfolder','<%=folder.LibraryParent %>');open_folder('<%=folder.LibraryId %>','<%=folder.LibraryName %>');title_top('<%=folder.LibraryId %>')" class="gal-table-name"><i class="fa fa-folder"></i><span class="item_name"><%=folder.LibraryName %></span></td>
                <td class="gal-table-date"><span title="<%=get_uploader.FullName %>" data-toggle="tooltip" data-placement="bottom"><%=upload_date %></span></td>
                <td class="gal-table-modified"><span title="<%=get_editor.FullName %>" data-toggle="tooltip" data-placement="bottom"><%=edit_date %></span></td>
                <td class="gal-table-options">
                    <i title="Mở thư mục" data-toggle="tooltip" data-placement="bottom" class="fa fa-folder-open w3-hover-text-teal"></i>
                    <i onclick="gal_rename('<%=folder.LibraryName %>','<%=folder.LibraryId %>')" title="Đổi tên" data-toggle="tooltip" data-placement="bottom" class="fa fa-edit w3-hover-text-teal"></i>
                    <i onclick="gal_move('<%=folder.LibraryId %>')" title="Di chuyển" data-toggle="tooltip" data-placement="bottom" class="fa fa-external-link w3-hover-text-teal"></i>
                    <i onclick="gal_delete(<%=folder.LibraryId %>)" title="Xóa" data-toggle="tooltip" data-placement="bottom" class="fa fa-trash w3-hover-text-teal"></i>
                </td>
            </tr>
            <%} %>
            <%var get_img = new TblLibraryController().FetchAll().Where(x => x.LibraryTrash == false && x.LibraryDelete == false && x.LibraryParent == id && x.LibraryType == 1); %>
            <%foreach (TblLibrary img in get_img)
              {
                  var get_uploader = new TblManagerController().FetchAll().Where(x => x.ManagerId == img.LibraryUploader).Single();
                  var get_editor = new TblManagerController().FetchAll().Where(x => x.ManagerId == img.LibraryEditor).Single();
                  string upload_date = "", edit_date = "";
                  DateTime date = DateTime.Parse(img.LibraryUploadDate.ToString());
                  upload_date = date.Day + "/" + date.Month + "/" + date.Year + " " + date.Hour + ":" + date.Minute;
                  date = DateTime.Parse(img.LibraryEditDate.ToString());
                  edit_date = date.Day + "/" + date.Month + "/" + date.Year + " " + date.Hour + ":" + date.Minute;
            %>
            <tr id="item<%=img.LibraryId %>">
                <td class="gal-table-name">
                    <img src="../Content/testdata/picture/<%=img.LibraryLink %>" alt="[img not found!]" onclick="gal_view_img(this,'<%=img.LibraryName %>')" title="Xem ảnh" data-toggle="tooltip" data-placement="bottom" />
                    <span><span class="item_name"><%=img.LibraryName %></span></span></td>
                <td class="gal-table-date"><span title="<%=get_uploader.FullName %>" data-toggle="tooltip" data-placement="bottom"><%=upload_date %></span></td>
                <td class="gal-table-modified"><span title="<%=get_editor.FullName %>" data-toggle="tooltip" data-placement="bottom"><%=edit_date %></span></td>
                <td class="gal-table-options">
                    <input class="gal-link-copy" id="link<%=img.LibraryId %>" value="../Content/testdata/picture/<%=img.LibraryLink %>" />
                    <i onclick="gal_copy(<%=img.LibraryId %>)" title="Sao chép link" data-toggle="tooltip" data-placement="bottom" class="fa fa-copy w3-hover-text-teal"></i>
                    <i onclick="gal_rename('<%=img.LibraryName %>','<%=img.LibraryId %>')" title="Đổi tên" data-toggle="tooltip" data-placement="bottom" class="fa fa-edit w3-hover-text-teal"></i>
                    <i onclick="gal_move('<%=img.LibraryId %>')" title="Di chuyển" data-toggle="tooltip" data-placement="bottom" class="fa fa-external-link w3-hover-text-teal"></i>
                    <i onclick="gal_delete(<%=img.LibraryId %>)" title="Xóa" data-toggle="tooltip" data-placement="bottom" class="fa fa-trash w3-hover-text-teal"></i>
                </td>
            </tr>
            <%} %>

            <%var get_snd = new TblLibraryController().FetchAll().Where(x => x.LibraryTrash == false && x.LibraryDelete == false && x.LibraryParent == id && x.LibraryType == 2); %>
            <%foreach (TblLibrary snd in get_snd)
              {
                  var get_uploader = new TblManagerController().FetchAll().Where(x => x.ManagerId == snd.LibraryUploader).Single();
                  var get_editor = new TblManagerController().FetchAll().Where(x => x.ManagerId == snd.LibraryEditor).Single();
                  string upload_date = "", edit_date = "";
                  DateTime date = DateTime.Parse(snd.LibraryUploadDate.ToString());
                  upload_date = date.Day + "/" + date.Month + "/" + date.Year + " " + date.Hour + ":" + date.Minute;
                  date = DateTime.Parse(snd.LibraryEditDate.ToString());
                  edit_date = date.Day + "/" + date.Month + "/" + date.Year + " " + date.Hour + ":" + date.Minute;
            %>
            <tr id="item<%=snd.LibraryId %>">
                <td class="gal-table-name"><i onclick="gal_play_audio(event,'<%=snd.LibraryLink %>')" title="Phát âm thanh" data-toggle="tooltip" data-placement="bottom" class="gal-play-audio-btn fa fa-volume-up w3-hover-text-teal"></i><i onclick="gal_stop_audio(event)" title="Dừng" data-toggle="tooltip" data-placement="bottom" class="gal-stop-audio-btn fa fa-pause w3-hover-text-teal"></i><span class="item_name"><%=snd.LibraryName %></span></td>
                <td class="gal-table-date"><span title="<%=get_uploader.FullName %>" data-toggle="tooltip" data-placement="bottom"><%=upload_date %></span></td>
                <td class="gal-table-modified"><span title="<%=get_editor.FullName %>" data-toggle="tooltip" data-placement="bottom"><%=edit_date %></span></td>
                <td class="gal-table-options">
                    <input class="gal-link-copy" id="link<%=snd.LibraryId %>" value="../Content/testdata/audio/<%=snd.LibraryLink %>" />
                    <i onclick="gal_copy(<%=snd.LibraryId %>)" title="Sao chép link" data-toggle="tooltip" data-placement="bottom" class="fa fa-copy w3-hover-text-teal"></i>
                    <i onclick="gal_rename('<%=snd.LibraryName %>','<%=snd.LibraryId %>')" title="Đổi tên" data-toggle="tooltip" data-placement="bottom" class="fa fa-edit w3-hover-text-teal"></i>
                    <i onclick="gal_move('<%=snd.LibraryId %>')" title="Di chuyển" data-toggle="tooltip" data-placement="bottom" class="fa fa-external-link w3-hover-text-teal"></i>
                    <i onclick="gal_delete(<%=snd.LibraryId %>)" title="Xóa" data-toggle="tooltip" data-placement="bottom" class="fa fa-trash w3-hover-text-teal"></i>
                </td>
            </tr>
            <%} %>

            <%var get_vid = new TblLibraryController().FetchAll().Where(x => x.LibraryTrash == false && x.LibraryDelete == false && x.LibraryParent == id && x.LibraryType == 3); %>
            <%foreach (TblLibrary vid in get_vid)
              {
                  var get_uploader = new TblManagerController().FetchAll().Where(x => x.ManagerId == vid.LibraryUploader).Single();
                  var get_editor = new TblManagerController().FetchAll().Where(x => x.ManagerId == vid.LibraryEditor).Single();
                  string upload_date = "", edit_date = "";
                  DateTime date = DateTime.Parse(vid.LibraryUploadDate.ToString());
                  upload_date = date.Day + "/" + date.Month + "/" + date.Year + " " + date.Hour + ":" + date.Minute;
                  date = DateTime.Parse(vid.LibraryEditDate.ToString());
                  edit_date = date.Day + "/" + date.Month + "/" + date.Year + " " + date.Hour + ":" + date.Minute;
            %>
            <tr id="item<%=vid.LibraryId %>">
                <td class="gal-table-name"><span class="gal-video-link" hidden="hidden"><%=vid.LibraryLink %></span><i onclick="gal_watch_video(this)" title="Xem video" data-toggle="tooltip" data-placement="bottom" class="fa fa-youtube-play w3-hover-text-teal"></i><span class="gal-video-name"><span class="item_name"><%=vid.LibraryName %></span></span></td>
                <td class="gal-table-date"><span title="<%=get_uploader.FullName %>" data-toggle="tooltip" data-placement="bottom"><%=upload_date %></span></td>
                <td class="gal-table-modified"><span title="<%=get_uploader.FullName %>" data-toggle="tooltip" data-placement="bottom"><%=edit_date %></span></td>
                <td class="gal-table-options">
                    <input class="gal-link-copy" id="link<%=vid.LibraryId %>" value="https://www.youtube.com/watch?v=<%=vid.LibraryLink %>" />
                    <i onclick="gal_copy(<%=vid.LibraryId %>)" title="Sao chép link" data-toggle="tooltip" data-placement="bottom" class="fa fa-copy w3-hover-text-teal"></i>
                    <i onclick="gal_rename('<%=vid.LibraryName %>','<%=vid.LibraryId %>')" title="Đổi tên" data-toggle="tooltip" data-placement="bottom" class="fa fa-edit w3-hover-text-teal"></i>
                    <i onclick="gal_move('<%=vid.LibraryId %>')" title="Di chuyển" data-toggle="tooltip" data-placement="bottom" class="fa fa-external-link w3-hover-text-teal"></i>
                    <i onclick="gal_delete(<%=vid.LibraryId %>)" title="Xóa" data-toggle="tooltip" data-placement="bottom" class="fa fa-trash w3-hover-text-teal"></i>
                </td>
            </tr>
            <%} %>
        </tbody>
    </table>
</body>
</html>
